{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2.0.0\n"
     ]
    }
   ],
   "source": [
    "#求导\n",
    "import tensorflow as tf\n",
    "print(tf.__version__)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "None None None\n"
     ]
    }
   ],
   "source": [
    "x = tf.constant(1.)\n",
    "a = tf.constant(2.)\n",
    "b = tf.constant(3.)\n",
    "c = tf.constant(4.)\n",
    "\n",
    "\n",
    "with tf.GradientTape() as tape:\n",
    "\ttape.watch([a, b, c])\n",
    "\ty = a**2 * x + b * x + c\n",
    "\n",
    "[dy_da, dy_db, dy_dc] = tape.gradient(y, [a, b, c])\n",
    "print(dy_da, dy_db, dy_dc)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "sigmoid 公式 \n",
    "$$s(x)=\\frac{1}{(1+e^{-x})}$$\n",
    "推倒过程  S1\n",
    "$$f(x)=\\frac{1}{s(x)}=1+e^{-x}$$\n",
    "S2 begin\n",
    "$$f'(x)=\\frac{s'(x)}{s(x)^2}$$\n",
    "Chain Rule \n",
    "$$\\frac{de^{u(x)}}{dx}=\\frac{de^u(x)}{du(x)} * \\frac{du(x)}{dx}$$\n",
    "yet\n",
    "$$\\frac{de^{u(x)}}{dx}=e^{u(x)}* \\frac{du(x)}{dx}$$\n",
    "S2 end\n",
    "$$f'(x)=\\frac{d}{dx}(1+e^{-x})=-e^{-x}=1-f(x)=1-\\frac{1}{s(x)}=\\frac{s(x)-1}{s(x)}$$\n",
    "S1 <==> S2\n",
    "sigmoid 导数 \n",
    "$$s(x)'=s(x) * (1-s(x))$$\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "tf.Tensor(0.25, shape=(), dtype=float32)\n"
     ]
    }
   ],
   "source": [
    "#sigmoid 导数计算   \n",
    "x = tf.constant(0.)\n",
    "with tf.GradientTape() as tape:\n",
    "    tape.watch([x])\n",
    "    y =  1/(1 + tf.exp(-x))\n",
    "[dy_dx] = tape.gradient(y,[x])\n",
    "print(dy_dx)\n",
    "    "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "isnot closed form solution\n",
    "LOSS\n",
    "$$(WX+B-Y)^{2}$$\n",
    "$$loss=\\sum_{i=0}^{n}{i}(wx_{i}+b-y_{i})^{2}$$\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "$$f(x) = x^{2}*sin(x)$$"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXkAAAD4CAYAAAAJmJb0AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjMsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+AADFEAAAgAElEQVR4nO3deXzU9YH/8dcnk8l9kJCTJJBw3wiEQ8GjKKJiRam2bj34WV27rdrW7XZX9+j+dttad2tbbevWWrXa1qr1piggglURBcINCRDuhNyEHOSczHx+fyS48BMVkpl8Zybv5+ORRzJH5vtmIG+++cxnPh9jrUVERMJThNMBREQkcFTyIiJhTCUvIhLGVPIiImFMJS8iEsYinQ5wqrS0NJufn+90DBGRkLJp06Y6a236mW4LqpLPz8+nqKjI6RgiIiHFGHP4027TcI2ISBhTyYuIhDGVvIhIGFPJi4iEMZW8iEgYU8mLiIQxlbyISBgLqnnyIiJOq25qZ1tZA/trWxiTlUBhfipJMW6nY/WaSl5EBry2Ti+/WFPKK5vLqW7qOO22CAMTc5K5fnouN88aRkSEcShl76jkRWRAW7evjvtf3cHhY60smJDJrILB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8iEsZU8iIiYUwlLyISxlTyIiJh7P8BrG9wyiTk2ywAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "x=np.arange(0,9,0.1)\n",
    "#幂运算\n",
    "y=np.power(x,2)*np.sin(x)\n",
    "plt.plot(x,y)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "tf.Tensor(66.38342, shape=(), dtype=float32)\n"
     ]
    }
   ],
   "source": [
    "x = tf.constant(9.)\n",
    "with tf.GradientTape() as tape:\n",
    "\ttape.watch([x])\n",
    "\ty = x**2*tf.sin(x)\n",
    "[dy_dx] = tape.gradient(y,[x])\n",
    "print(-dy_dx)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
